package com.ibangnuo.manage.controller.employee;

import com.ibangnuo.api.employee.AgentControllerApi;
import com.ibangnuo.framework.domain.ext.AgentExt;
import com.ibangnuo.framework.domain.request.AgentQueryRequest;
import com.ibangnuo.framework.model.response.ObjectResult;
import com.ibangnuo.framework.model.response.QueryResponseResult;
import com.ibangnuo.framework.model.response.ResponseResult;
import com.ibangnuo.manage.service.employee.AgentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author:ly
 * @Data:2019/12/27 17:21
 * @Verdion:1.0
 */
@RequestMapping("/agentEntity")
@RestController
public class AgentController implements AgentControllerApi {

    @Autowired
    private AgentService agentService;

    @Override
    @GetMapping("/agent")
    public QueryResponseResult query() {
      return  agentService.query();
    }


    /**
     * 分页列表查询
     * @param agentQueryRequest
     * @return
     */
    @PostMapping("/list")
    @Override
    public QueryResponseResult findList(@RequestBody AgentQueryRequest agentQueryRequest) {
        return agentService.findList(agentQueryRequest);
    }

    /**
     * 添加账号信息进入用户表
     * 添加代理商
     * @param agentExt
     * @return
     */
    @PostMapping("/add")
    @Override
    public ResponseResult add(@RequestBody AgentExt agentExt) {
        return agentService.add(agentExt);
    }

    /**
     * 根据id查找
     * @param id
     * @return
     */
    @GetMapping("/findById/{id}")
    @Override
    public ObjectResult findById(@PathVariable("id") String id) {
        return agentService.findById(id);
    }

    /**
     * 根据id修改
     * @param id
     * @param agentExt
     * @return
     */
    @PostMapping("/update/{id}")
    @Override
    public ResponseResult update(@PathVariable("id") String id, @RequestBody AgentExt agentExt) {
        return agentService.update(id,agentExt);
    }

    @GetMapping("/delete/{id}")
    @Override
    public ResponseResult delete(@PathVariable("id") String id) {
        return agentService.delete(id);
    }

    /**
     * 查询全部代理商
     * @return
     */
    @GetMapping("/findAll")
    @Override
    public ObjectResult findAll() {
        return agentService.findAll();
    }

    /**
     * 代理商人数统计
     * @return
     */
    @GetMapping("/statistic")
    @Override
    public ObjectResult statistic() {
        return agentService.statistic();
    }

    /**
     * 查找自己与旗下的代理商
     * @return
     */
    @GetMapping("/findByParentIdAndMySelf/{id}")
    @Override
    public ObjectResult findByParentIdAndMySelf(@PathVariable("id") String id) {
        return agentService.findByParentIdAndMySelf(id);
    }

    /**
     * 查找当前登录代理商
     * @return
     */
    @GetMapping("/findAgent")
    @Override
    public ObjectResult findAgent() {
        return agentService.findAgent();
    }


}
